/*!
\file AlgorithmVisualizer.h
\brief Contains declaration of AlgorithmVisualizer.
\ingroup GUI
*/

#ifndef ALGORITHMVISUALIZER_H
#define ALGORITHMVISUALIZER_H

#include"Algorithm.h"
#include"GraphVisualizer.h"
#include"DManager.h"
#include"GraphAccessWidget.h"
#include"ContainerVisualizer.h"
#include"AlgorithmLogArea.h"

#include<QWidget>
#include<QHBoxLayout>
#include<QMessageBox>
#include<QTimer>

/*!
\class AlgorithmVisualizer
\brief Widget designed to visualize one specific Algorithm. Contains GraphVisualizer, ContainerVisualizer, GraphAccessWidget and AlgorithmLogArea.
\ingroup GUI
*/

class AlgorithmVisualizer: public QWidget{
Q_OBJECT
public:
	AlgorithmVisualizer( Algorithm *a, QWidget *parent = 0 );
	//!< Constructor.
	~AlgorithmVisualizer();
	//!< Destructor.
	VisualizationSettings *settings()const{ return m_graphVisualizer->settings(); }
	//!< Returns the used VisualizationSettings.
private:
	QHBoxLayout *m_layout;
	QWidget *m_childWidget;
	QVBoxLayout *m_childLayout;
	QTimer *m_timer;
	Algorithm *m_algorithm;
	GraphVisualizer *m_graphVisualizer;
	GraphAccessWidget *m_accessWidget;
	QList<ContainerVisualizer*> m_containers;
	AlgorithmLogArea *m_logArea;
	
	ContainerVisualizer *_container( int i );
private slots:
	void _requestUpdate();
	void _requestTimedUpdate();
	void _requestStopTimedUpdate();
	void _requestPlay();
public slots:
	void _accessNode(int id);
	//!< Called by ActionCommunicator when a Node is accessed.
	void _accessEdge(int id);
	//!< Called by ActionCommunicator when an Edge is accessed.
	void _addContainer(int id);
	//!< Called by ActionCommunicator when a Container is added.
	void _removeContainer( int id );
	//!< Called by ActionCommunicator when a Container is removed.
	void _containerNewElement( int container, int i );
	//!< Called by Actioncommunicator when a new ContainerElement is added to a Container.
	void _containerRemoveElement( int container, int i );
	//!< Called by ActionCommunicator when a ContainerElement is removed from a Container.
	void _containerSetNode( int container, int i, int nodeID, QString label );
	//!< Called by ActionCommunicator when a Node is set to a ContainerElement.
	void _containerSetEdge( int container, int i, int from, int to, QString label = "" );
	//!< Called by ActionCommunicator when an Edge is set to a ContainerElement.
	void _containerSetData( int container, int i, QString data );
	//!< Called by ActionCommunicator when data is set to a ContainerElement.
	void _logComment( QString comment );
	//!< Called by ActionCommunicator when it should display a comment.
};

#endif
